#pragma once

#include "Material.h"
#include "Vector3.h"
#include "Vector4.h"
#include "Ray.h"

#include <cstdlib>

namespace RayTracer
{

	class CPrimitive
	{
	public:
		CPrimitive(void);
		virtual ~CPrimitive(void);

		enum PrimitiveType
		{
			SPHERE = 1,
			PLANE
		};

		enum IntersectionStatus
		{
			RAY_IN_PRIMITIVE = -1,		// Ray started inside primitive
			RAY_MISS = 0,					// Ray missed primitive
			RAY_HIT = 1						// Ray hit primitive
		};

		virtual PrimitiveType getType() = 0;
		virtual IntersectionStatus IntersectRay(CRay& ray, float& dist) = 0;
		virtual CVector3 getNormal(const CVector3& pos) = 0;

		virtual CVector4 getColor(const CVector3& /*pos*/) { return m_Material.getColor(); }

		virtual void setLight(const bool& isLight) { m_IsLight = isLight; }
		bool isLight() { return m_IsLight; }

		CMaterial* getMaterial() { return &m_Material; }
		void setMaterial(const CMaterial& material) { m_Material = material; }

		void setName(const char* name);
		char* getName() { return m_Name; }

	private:
		CMaterial m_Material;
		char* m_Name;
		bool m_IsLight;		// Flag: true -> light source, false -> not light source
	};

}